import { defineStore } from 'pinia';
import { OrganizationInfoVO } from '@/entiy/vo/OrganizationInfoVO.ts';
import RequestService from '@/service/RequestService.ts';
import PromiseUtils from '@/utils/PromiseUtils.ts';

export const useCompanyPermManagerStore = defineStore('useCompanyPermManagerStore', {
    state: () => {
        return {
            orgTreeList: [] as OrganizationInfoVO[]
        };
    },

    getters: {},

    actions: {
        // 查询机构列表
        async getOrgTreeListByName () {
            const result = await RequestService.post<OrganizationInfoVO[]>('/get-organization-info-list-by-name', {});
            if (result.isError) {
                return PromiseUtils.reject(result.errorMsg);
            }

            this.orgTreeList = result.bizDta == null ? [] : result.bizDta;
        }
    }
});
